OCX sample application

Project|References:

No Crystal References required

Project|Components:

Crystal Report Control

Form1

Private Sub Form_Load()

Open the report.

CrystalReport1.ReportFileName = App.Path & "\OCX_to_RDC.rpt"

Change the location of the database.

CrystalReport1.DataFiles(0) = App.Path & "\xtreme.mdb"

Pass the parameter value to the main report.

CrystalReport1.ParameterFields(0) = "Param1;Main Report Param;True"

Pass the selection formula to the main report.

CrystalReport1.ReplaceSelectionFormula _ 
"{Customer.Last Year's Sales} < 50000.00"

Open the subreport.

CrystalReport1.SubreportToChange = "Sub1"

Change the location of the database in the subreport.

CrystalReport1.DataFiles(0) = App.Path & "\xtreme.mdb"

Pass the formula to the subreport.

CrystalReport1.Formulas(0) = "Formula1= " & "'Subreport Formula'"

Set CrystalReport1 back to using the main report.

CrystalReport1.SubreportToChange = ""
End Sub
Private Sub Command1_Click()

Set the destination to window.

CrystalReport1.Destination = crptToWindow

Preview the Report.

CrystalReport1.Action = 1
End Sub
Private Sub Command2_Click()

Set the printer driver.

CrystalReport1.PrinterDriver = "HPPCL5MS.DRV"

Set the printer port.

CrystalReport1.PrinterName = "HP LaserJet 4m Plus"

Set the printer name.

CrystalReport1.PrinterPort = "\\Vanprt\v1-1mpls-ts"

Set the destination to printer.

CrystalReport1.Destination = crptToPrinter

Print the report.

CrystalReport1.Action = 1
End Sub
Private Sub Command3_Click()

Set the Report to be exported to Rich Text Format.

CrystalReport1.PrintFileType = crptRTF

Set the Destination to Disk.

CrystalReport1.Destination = crptToFile

Set the path and name of the exported document.

CrystalReport1.PrintFileName = App.Path & "\OCXExport.rtf"

Export the report.

CrystalReport1.Action = 1
End Sub


Seagate Software IMG Holdings, Inc.
http://www.seagatesoftware.com
Support services:
http://support.seagatesoftware.com